package main

import "github.com/gin-gonic/gin"

func main() {
	r := gin.Default()

	f := func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "POST请求",
		})
	}
	//路由分组用于将多个路由进行统一的处理
	shop := r.Group("/shopping")
	{
		shop.GET("/index", f) // /shopping/index
		shop.GET("/home", f)  // /shopping/home
	}

	blog := r.Group("/blog")
	{
		blog.GET("/index", f)
		blog.GET("/home", f)
	}

	// 路由组也是支持嵌套的
	app01 := r.Group("/app01")
	{
		app01.GET("/index", f) // /app01/index
		ashop := app01.Group("/shopping")
		{
			ashop.GET("/bed", f)  // /app01/shopping/bed
			ashop.GET("/food", f) // /app01/shopping/food
		}
	}
}
